<?php

declare(strict_types=1);

namespace App\JsonRpc;

use App\Interface\TestServiceInterface;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\ConfigInterface;
use Hyperf\RpcServer\Annotation\RpcService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

#[RpcService(
    name: "TestService",
    publishTo: "nacos"
)]
class TestService implements TestServiceInterface
{
    public function test(): array
    {
        return ['test'];
    }

    /**
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getConfig(): array
    {
        $config = ApplicationContext::getContainer()->get(ConfigInterface::class);

        return [
            'database' => $config->get('database'),
            'redis' => $config->get('redis')
        ];
    }
}